﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Collections;
using GPCSC.Webs;
using GPCSC.Model;
using NickLee.Common;
using System.Text;
using ExtAspNet;



namespace GPCSC.Web.SHFW
{
    public partial class PY : PageBase
    {
        CL_USER_S user = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                btnDelete.OnClientClick = Grid1.GetNoSelectionAlertReference("至少选择一项！");
                btnNew.OnClientClick = Window1.GetShowReference("SYS_TZt.aspx", "新增");
              //  btnNew.OnClientClick = "<script>openNew();</script>";
                f_bound();
            }
        }
        protected void f_bound()
        {
            user = reUser();
            DataSet ds = new CL_PY().F_bound(user.CL_USER_SOID.ToString());
            if (ds.Tables.Count > 0)
            {
                Grid1.DataSource = ds.Tables[0];
                Grid1.DataBind();
            }
            
        }
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            GPCSC.Webs.databyhtable dh = new databyhtable();
            Hashtable htable = new Hashtable();
            //StringBuilder sb = new StringBuilder();
            foreach (int row in Grid1.SelectedRowIndexArray)
            {
                htable.Clear();
                htable.Add("Isdel",1);
                dh.databyhtables(htable, "update", "CL_PY", "pyid", Grid1.DataKeys[row][0].ToString());
                //sb.Append(Grid1.DataKeys[row][0].ToString());
                //sb.Append(",");
            }
            f_bound();
            Alert.ShowInTop("删除成功!");
        }
        protected void Window1_Close(object sender, EventArgs e)
        {
            f_bound();

        }
        
        protected string GetEditUrl(object id)
        {
            return "javascript:" + Window1.GetShowReference("PYEdit.aspx?id=" + id.ToString());
        }

        protected string GetHidePostBackReference()
        {
            Alert.ShowInTop("保存成功！");
            return "";
        }



        public Hashtable f_getElements(Hashtable o_uiTable)
        {
            //UIFactory Get Values as Hashtable:界面工厂获取值，并保存在哈希表
            base.o_uiTable.Clear();
            base.o_uiTable = UIFactory.UIFactory_Get(this);
            return base.o_uiTable;
        }
        public CL_USER_S reUser()
        {

            byte[] userInfo = (byte[])base.o_baseTable[c_obj.s_userInfo];
            Hashtable userInfoTable = CompressData.UnCompressHashtable(userInfo);
            CL_USER_S users = (GPCSC.Model.CL_USER_S)userInfoTable["SYS_USER"];
            return users;
        }

    }
}